<!DOCTYPE html>
<html lang="zh">
<head>
	<meta charset="UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../css/base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/mui.min.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/html-base.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/train.css"/>

    <style type="text/css">
    	.jie-tit-div{
    		border-top: 1px dashed #D3D3D3;
    	}
    	.course-chapter{
		    padding: 0 0.4rem;
    	}
    	.course-section{
    		border-top: 1px solid #D3D3D3;
    	}
    	.first-section{
    		border-top: none;
    	}
    </style>
    <script type="text/javascript" src="../../script/newresize.js"></script>
</head>
<body>
	<div id="current_page" class="detcontainer">
		<a class="mui-icon mui-icon-left-nav detback" onclick="backClick()"></a>
		<div class="detwrapper">
			<div class="det-top-img"><img id="course_image" src="../../image/default-pic03.png"/></div>
			<div class="det-price-box">
				<div class="det-part1">
					<span id="course_name" class="course-name"></span>
					<span onclick="onShareClick();" class="icon-share icon-share-blue"><span>分享</span></span>
				</div>
				<div class="det-part2">
					<span id="star1" class="icon-star"></span>
					<span id="star2" class="icon-star"></span>
					<!-- <span id="star3" class="icon-star icon-star-on"></span> -->
					<span id="star3" class="icon-star"></span>
					<span id="star4" class="icon-star"></span>
					<span id="star5" class="icon-star"></span>
					
					<span id="teachername" class="course-teach">主讲人:</span>
					<span id="learn_num" class="course-people">0人学过</span>
					<span id="course_period" class="course-time">0课时</span>
				</div>
				<div class="det-part3">
					<span id="course_fee" class="price-txt">￥0.00</span>
				</div>
			</div>
			<div class="det-centercont">
				<ul class="det-navtab" id="det-navtab">
					<li class="active">介绍</li>
					<li>目录</li>
					<li>评价</li>
				</ul>
				<!--隐藏的浮动导航-->
				<!--<ul class="det-navtab  fixnav">
					<li class="active">介绍</li>
					<li>目录</li>
					<li>评价</li>
				</ul>-->
			</div>
			<div class="det-cardwrapper">
				<div class="det-cardcontent">
					<div class="mintitbox">课程简介：</div>
					<div id="course_describe" class="train-txt">
						<!-- <p>作为一个跨境消费者，在了解了跨境电商企业、产品、政策的基本知识之后，你一定特别想知道有哪些跨境电商平台。实际上，跨境电商平台时信息流、资金流、物流三流合一的具有巨大潜在价值的平台。跨境电商平台未来将朝哪个方向发展？会给跨境消费者带来哪些体验？这是非常值得期待的。</p>
						<p>学完课程你会：</p>
						<p>1.了解跨境电商业态格局和趋势；</p>
						<p>2.了解跨境电扇平台运营模式；</p>
						<p>3.了解跨境电商平台给跨境消费者带来的体验。</p> -->
					</div>
					<div class="mintitbox">教师简介：</div>
					<div id="teacherinfo" class="train-txt">
						<!-- <p>祁振国，毕业于天津外国语学院，后进入清华大学继续教育学院进修物流专业课程，以优异的成绩毕业。曾任大田-联邦快递区域总经理，美国penske物流区域总经理，后进入百利威物流任分公司总经理，现任北京瑞博物流有限公司总经理，是业内著名职业经理人。有丰富的物流企业从业经验，熟知物流业内的发展历程，对物流业现状及未来发展趋势有深刻独到的简介。</p> -->
					</div>
					<div class="mintitbox">购买须知：</div>
					<div id="buyinfo" class="train-txt"></div>
				</div>
				<div class="det-cardcontent" style="display: none;">
					<div id="chapter_list" class="coursewrapper course-chapter">
						<!-- <div class="course-listcont course-section first-section"><p class="course-tit">第一章 : 跨境电商平台</p>
						</div>
						<div class="course-listcont jie-tit-div"><p class="course-tit">第一节 : 跨境电商平台</p>
						</div>
						<ul class="listbox">
							<li class="list-item list-freecourse">
								<span class="list-labelbox"><span>视频</span></span>
								<a class="list-title">网民也可以跨境（一）</a>
								<span class="list-iconbox">可试学</span>
							</li>
						</ul>
						<ul class="listbox">
							<li class="list-item list-freecourse">
								<span class="list-labelbox"><span>视频</span></span>
								<a class="list-title">网民也可以跨境（二）</a>
								<span class="list-iconbox">可试学</span>
							</li>
						</ul>
						<div class="course-listcont course-section"><p class="course-tit">第二章 : 网民也可以跨境</p>
						</div>
						<ul class="listbox">
							<li class="list-item list-freecourse">
								<span class="list-labelbox"><span>视频</span></span>
								<a class="list-title">网民也可以跨境（一）</a>
								<span class="list-iconbox">可试学</span>
							</li>
							<li class="list-item">
								<span class="list-labelbox"><span>视频</span></span>
								<a class="list-title">网民也可以跨境（二）</a>
								<span class="list-iconbox"><img src="../../image/icon_suo.png"/></span>
							</li>
						</ul> -->
					</div>
					<div class="noSign" hidden="hidden" id="noData1">
						<img src="../../image/default-pic03.png" width="60%">
						<p class="font16 top_15 base_dark_grey" >
							暂无数据
						</p>
					</div>
					<div class="loadFailure" hidden="hidden" id="noNet1">
						<img src="../../image/icon_img01.png" width="60%">
						<p class="" >
							数据加载失败
						</p>
						<p>
							请检查您的网络
						</p>
						<button type="button" class="mui-btn mui-btn-outlined" onclick="loadChapterData()">
							重新加载
						</button>
					</div>
				</div>
				<div class="det-cardcontent" style="display: none;">
					<div class="judgewrapper">
						<div class="editjudgebox">
							<img src="../../image/icon_zedit.png"/>
							<span>评价该课程</span>
						</div>
						<div id="comment_list" class="judgelistcont">
							<!-- <div class="judge-item">
								<div class="judge-item-top">
									<div class="judge-userimg"><img src="../../image/expimg01.png"/></div>
									<div class="judge-infobox">
										<div class="clearfix">
											<p class="judge-username">会飞的鱼</p>
											<span class="judge-info-time">2019-03-20</span>
										</div>
										<div class="starbox">
											<span class="icon-star icon-star-on"></span>
											<span class="icon-star icon-star-on"></span>
											<span class="icon-star icon-star-on"></span>
											<span class="icon-star"></span>
											<span class="icon-star"></span>
										</div>
									</div>
								</div>
								<div class="judge-item-txt">讲的很好，听后受益匪浅，还会继续学习的。讲的很好，听后受益匪浅，还会继续学习的。讲的很好，听后受益匪浅，还会继续学习的。</div>
							</div> -->
						</div>
						<div class="noSign" hidden="hidden" id="noData2">
							<img src="../../image/default-pic04.png" width="60%">
							<p class="font16 top_15 base_dark_grey" >
								暂无评论
							</p>
						</div>
						<div class="loadFailure" hidden="hidden" id="noNet2">
							<img src="../../image/icon_img01.png" width="60%">
							<p class="" >
								数据加载失败
							</p>
							<p>
								请检查您的网络
							</p>
							<button type="button" class="mui-btn mui-btn-outlined" onclick="loadCommentData()">
								重新加载
							</button>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="detbotcont" hidden="hidden">
		<div class="botwrapper">
			<a class="bot-phone" id="mobile" href="tel:13764567708">
				<span class="bot-icon icon-service"></span>
				<span class="bot-label">客服</span>
			</a>
			<div class="bot-sc">
				<span class="bot-icon icon-storeup"></span>
				<span class="bot-label">收藏</span>
			</div>
			<div class="bot-buy">
				<p class="freestudy">免费试学</p>
				<a id="course_buy" href="javascript:;" style="width: 50%;"  class="gotobuy" onclick="buyCourse()">立即购买</a>
			</div>
		</div>
	</div>
	<div class="shareshade"></div>
	<div id="share_div" class="share-div" hidden="hidden">
		<div id="share_img_div" class="share-codecont">
			<div class="sharecodebox"><img id="share_img" class="share-img" src="../../image/default-pic01.png" alt=""></div>
			<div class="sharecodetxt">
				扫码查看：
				<div id="qrcode_img" class="erweima">
				</div>
				<!-- <img id="qrcode_img" src="../../image/img_code.png" alt="" class="erweima"> -->
			</div>
		</div>
	</div>
	<div class="sharelay">
		<span class="share-tit">分享至</span>
		<div class="sharewrapper">
			<div class="sharecont">
				<div class="sharetr">
					<div onclick="setupScreenCapture(0);" class="sharetd">
						<div class="shareicon"><img src="../../image/share-wx.png" alt=""></div>
						<p class="sharetxt">微信好友</p>
					</div>
					<div onclick="setupScreenCapture(1);" class="sharetd">
						<div class="shareicon"><img src="../../image/share-pyq.png" alt=""></div>
						<p class="sharetxt">朋友圈</p>
					</div>
					<div onclick="setupScreenCapture(2);" class="sharetd">
						<div class="shareicon"><img src="../../image/share-qq.png" alt=""></div>
						<p class="sharetxt">QQ好友</p>
					</div>
					<div onclick="setupScreenCapture(3);" class="sharetd">
						<div class="shareicon"><img src="../../image/share-qqzone.png" alt=""></div>
						<p class="sharetxt">QQ空间</p>
					</div>
					<div onclick="setupScreenCapture(4);" class="sharetd">
						<div class="shareicon"><img src="../../image/share-wb.png" alt=""></div>
						<p class="sharetxt">微博</p>
					</div>
				</div>
				<div class="sharetr">
					<div onclick="setupScreenCapture(5);" class="sharetd" id="copylink">
						<div class="shareicon"><img src="../../image/share-link.png" alt=""></div>
						<p class="sharetxt">复制链接</p>
					</div>
					<div onclick="setupScreenCapture(6);" class="sharetd" id="downimg">
						<div class="shareicon"><img src="../../image/share-down.png" alt=""></div>
						<p class="sharetxt">保存图片</p>
					</div>
				</div>
			</div>
		</div>
		<div onclick="onCancelClick();" class="share-cancel">取消</div>
	</div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/mui.min.js"></script>
<script type="text/javascript" src="../../script/MD5.js"></script>
<script type="text/javascript" src="../../script/requestTool.js"></script>
<script type="text/javascript" src="../../script/timeStampTool.js"></script>
<script type="text/javascript" src="../../script/getToken.js"></script>
<script type="text/javascript" src="../../script/v3.1.1/layer.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/public-train.css"/>
<script type="text/javascript" src="../../script/html2canvas.js"></script>
<script type="text/javascript" src="../../script/qrcode.min.js"></script>
<script type="text/javascript" src="../../script/jquery.qrcode.min.js"></script>
<script type="text/javascript" src="../../script/trainShare.js"></script>
<script type="text/javascript" src="../../script/utils/payUtils.js"></script>
<script type="text/javascript">
	var commentArr = new Array();
	var chapterArr = new Array();
	var page = 1;
	var rows = 10;
	var dropRefreshCount = 0;
	var buyStatus = 0;
	var currentCid;
	var currentScore = 5;
	var collectioning = false;//收藏中，防止因网络卡顿多次请求
	var courseData;
	$(function(){
		$(".det-navtab li").on("click",function(){
			$(".det-navtab li").removeClass("active");
			var idx = $(this).index();
			$.each($(".det-navtab"), function(i,e) {
				$(e).find("li").eq(idx).addClass("active");
			});
			$(".det-cardcontent").hide().eq(idx).show();
			if(idx == 1 || idx == 2){
				$(".gotobuy").css("width","100%").siblings(".freestudy").hide();
			}else if(idx == 0){
				$(".gotobuy").css("width","50%").siblings(".freestudy").show();
			}
		});
		//免费试学
		$(".freestudy").on("click",function(){
			$(".det-navtab li").removeClass("active");
			$.each($(".det-navtab"), function(i,e) {
				$(e).find("li").eq(1).addClass("active");
				$(".det-cardcontent").hide().eq(1).show();
			});
			$(this).siblings(".gotobuy").css("width","100%");
			$(this).hide();
		})
		
		//评价课程
		$(".editjudgebox").on("click",function(){
			if (buyStatus != 1) {
				mui.toast("购买后才能评价课程哦~");
				return; 
			}
			var shtml = '<div class="judgepop">';
				shtml+=		'<div class="judgestar">';
				shtml+=			'<div class="starbox">';
				shtml+=				'<span id="tapStar1" class="icon-star tap-star icon-star-on"></span>';
				shtml+=				'<span id="tapStar2" class="icon-star tap-star icon-star-on"></span>';
				shtml+=				'<span id="tapStar3" class="icon-star tap-star icon-star-on"></span>';
				shtml+=				'<span id="tapStar4" class="icon-star tap-star icon-star-on"></span>';
				shtml+=				'<span id="tapStar5" class="icon-star tap-star icon-star-on"></span>';
				shtml+=			'</div>';
				shtml+=			'<p id="score_title" class="judgestartxt">推荐，课程非常棒</p>';
				shtml+=		'</div>';
				shtml+=		'<div class="judgetxtcont">';
				shtml+=			'<textarea name="" rows="" cols="" placeholder="请尽可能详尽描述你的学习经历，例如学习成果、课程内容、讲师风格、数学服务等。200字以内。" id="txtval"></textarea>';
				shtml+=		'</div>';
				shtml+=		'<div class="popbtnbox">';
				shtml+=			'<span class="cancel">取消</span>';
				shtml+=			'<span class="tijiao">提交</span>';
				shtml+=		'</div>';
				shtml+=	'</div>';
			layer.open({
				type:1,
				title:false,
				closeBtn:0,
				area:["90%","auto"],
				skin:'judgexxx',
				content:shtml,
				success:function(layero,index){
					$(".popbtnbox .cancel").on("click",function(){
						layer.close(index);
					})
					$(".tap-star").on("click", function(){
						var starid = $(this).attr('id');
						var score = parseInt(starid.substring(starid.length - 1));
						switch(score){
							case 1:
							$('#score_title').text('低评：不满意，比较差');
							break;
							case 2:
							case 3:
							$('#score_title').text('中评：感觉一般，仍可改善');
							break;
							case 4:
							case 5:
							$('#score_title').text('推荐，课程非常棒');
							break;
						}
						//设置点击星星后选中未选中的状态
						for (var i = 1; i < 6; i++) {
							if (i <= score) {
								$('#tapStar'+i).addClass('icon-star-on');
							}else{
								$('#tapStar'+i).removeClass('icon-star-on');
							}
						}
						currentScore = score;
					})
					$(".popbtnbox .tijiao").on("click",function(){
						var str = $("#txtval").val();
						if(str==""){
							layer.msg("您还没有填写评价内容");
							$("#txtval").focus();
						}else{
							submitCommentClick(str);
							layer.close(index);
						}
					})
				}
			})
		})
	})
	apiready = function(){
	    loadData();//课程详情
	    loadCommentData();//评论数据
		loadCollectionStatus();//收藏状态
		loadBuyStatus();//获取支付状态
		setPullUpRefresh();
		setupCollectionClick();
	    setupQRCode();
		api.addEventListener({
			name: 'aliPayResult'
		}, function(ret, err) {
			console.log("支付结果:"+JSON.stringify(ret));
			if(ret.value.code==="4000") {
				api.closeToWin({
					name: 'train-det-kc'
				});
				api.toast({
					msg: '支付成功'
				});
				loadBuyStatus();//刷新课程状态
			}
		});
	};
	function setupQRCode(){
		var width = $('body').width();
		var imgW = width * (55.7 / 320);
		currentUrl = 'http://cftrain.cfnet.org.cn/home/Course/details?id='+api.pageParam.id;
		$("#qrcode_img").qrcode({width:imgW,height:imgW,correctLevel:0,text:currentUrl});
	}
	function loadCollectionStatus(){
		var params = {
			type : 2,
			uid : $api.getStorage('cfnetppuid'),
			typeid : api.pageParam.id,
			status : 1
		};
		// console.log(JSON.stringify(params)+'\n'+url_train_getCollection);
		cfnetppPOST(url_train_getCollection, params, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					var c_status = data.data.status;
					if (c_status == 1) {
						$('.bot-sc').addClass("ysc");
					}
				}
			}
		});
	}
	//设置收藏点击事件
	function setupCollectionClick(){
		$(".bot-sc").on("click",function(){
			if($(this).hasClass("ysc")){
				onCollectionClick(2, function(status, message){
					if (status == true) {
						$('.bot-sc').removeClass("ysc");
						mui.toast("取消收藏成功");
					}else{
						mui.toast(message);
					}
				});
			}else{
				onCollectionClick(1, function(status, message){
					if (status == true) {
						$('.bot-sc').addClass("ysc");
						mui.toast("收藏成功");
					}else{
						mui.toast(message);
					}
				});
			}
		});
	}
	//点击收藏回调函数
	function onCollectionClick(status, callBack){
		if (collectioning == true) {
			return;
		}
		var params = {
			type : 2,
			uid : $api.getStorage('cfnetppuid'),
			typeid : api.pageParam.id,
			status : status
		};
		collectioning = true;
		// console.log(JSON.stringify(params)+'\n'+url_train_changeCollection);
		cfnetppPOST(url_train_changeCollection, params, false, function(data, status){
			collectioning = false;
			if (status == 'success') {
				if (data.code == 200) {
					if (callBack) {
						callBack(true, data.message);
					}
				}else{
					if (callBack) {
						callBack(false, data.message);
					}
				}
			}else{
				if (callBack) {
					callBack(false, '网络异常，请检查网络');
				}
			}
		});
	}
	function loadBuyStatus(){
		buyStatus=api.pageParam.buyStatus;
		getPayStatus(api.pageParam.id,112,function (status) {
			console.log("支付结果:"+status);
			if(status===PAYSTATUS.PAY_SUCCESS){
				buyStatus=1;
				$('.detcontainer').attr('style', 'padding-bottom:0;');
				$('.detbotcont').hide();
			}else if(status===PAYSTATUS.PAY_AUDITING){
				$('.detbotcont').show();
				$('#course_buy').text("待审核");
				$("#course_buy").attr("disabled",true).css("pointer-events","none");
			}else if(status===PAYSTATUS.PAY_WAIT){
				$('.detbotcont').show();
				$('#course_buy').text("待到账");
				$("#course_buy").attr("disabled",true).css("pointer-events","none");
			}else{
				$('.detcontainer').attr('style', 'padding-bottom:1.46rem;');
				$('.detbotcont').show();
			}
		});
	}
	// 上拉加载
	function setPullUpRefresh() {
		api.addEventListener({
			name : 'scrolltobottom'
		}, function(ret, err) {
			if (dropRefreshCount >= rows) {
				dropRefreshCount = 0;
				page++;
				loadData();
			}
		});
	}
	function loadData(){
		var params = {
			id : api.pageParam.id
		};
		cfnetppPOST(url_train_getCourse, params, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					courseData = data.data;
					setupCourseData(courseData);
				}
			}
		});
	}
	//加载章节数据
	function loadChapterData() {
		api.showProgress({
		    style: 'default',
		    animationType: 'fade',
		    title: '数据加载中...',
		    text: '',
		    modal: false
		});
		var params = {
			cid : currentCid
		};
		console.log("cid:"+currentCid);
		cfnetppPOST(url_freeChapterUrl, params, false, function(data, status){
			api.hideProgress();
			if (status == 'success') {
				if (data.code == 200) {
					$('#chapter_list').html('');
					var chapters = data.data;
					if (chapters != undefined && chapters != null && chapters.constructor == Array && chapters.length > 0) {
						$('#noData1').hide();
						$('#noNet1').hide();
						chapterArr = chapters;
						setupChapterData();
					}else{
						$('#noData1').show();
						$('#noNet1').hide();
					}
				}else{
					$('#chapter_list').html('');
					$('#noData1').show();
					$('#noNet1').hide();
				}
			}else{
				$('#chapter_list').html('');
				$('#noData1').hide();
				$('#noNet1').show();
			}
		});
	}
	function setupChapterData(){
		var tagIndex = 0;
		var partIndex = 0;
		var chapterIndex = 0;
		for (var i = 0; i < chapterArr.length; i++) {
			var chapterData = chapterArr[i];
			var content_type = chapterData.content_type;
			var cellHtml = '';
			if (content_type == 'tag') {
				tagIndex++;
				partIndex = 0;
				chapterIndex = 0;
				cellHtml = tagCellHtml(i, tagIndex, chapterData);
			}else if (content_type == 'part') {
				partIndex++;
				cellHtml = partCellHtml(i, partIndex, chapterData);
			}else{
				chapterIndex++;
				cellHtml = chapterCellHtml(i, tagIndex, chapterIndex, chapterData);
			}
			$('#chapter_list').append(cellHtml);
		}
		setupChapterCellClick();
	}
	//设置课时点击
	function setupChapterCellClick(){
		$('.chapter-cell').unbind('click');
		console.log($('.chapter-cell').length);
		$('.chapter-cell').click(function(){
			console.log("hahha");
			var isFree = $(this).attr('isFree');
			if (isFree == 0) {
				api.toast({
				    msg: '请先购买课程!'
				});
				return;
			}
			var index = $(this).attr('index');
			var chapterData = chapterArr[parseInt(index)];
			setupChapterJump(chapterData);
		});
	}
	//设置课时跳转
	function setupChapterJump(data){
		var content_type = data.content_type;
		data["vid"] = data.id;
		data["title"] = data.cdetailtitle;
		var type_name = '';
		if (content_type == 'hdresource') {//互动资源
			openHDResource(data);
		}else if(content_type == 'discuss'){//讨论
			openDiscuss(data);
		}else if(content_type == 'tests'){//测验
			openTest(data);
		}else if(content_type == 'richtext'){//富文本
			openRichText(data);
		}else if(content_type == 'video'){//视频
			openVideo(data);
		}else if(content_type == 'doc'){//文档
			openDoc(data);
		}
	}
	function openDiscuss(data){
		data["chapterid"] = data.id;
		data["type"] = 0;
		api.openWin({useWKWebView:true,
		    name: 'Student_Mocc_DiscussChapterWindow',
		    url: '../Study/Student_Mocc_DiscussChapterWindow.html',
		    bounces: false,
		    pageParam: data
		});
	}
	function openVideo(data){
		var sourceUrl = data.sourceUrl;
		var rid = data.rid;
		if (sourceUrl != null && sourceUrl != '' && sourceUrl.indexOf("http://") >=0 ) {
			rid = sourceUrl;
		}
		data["videourl"] = rid;
		data["videoname"] = data.cdetailtitle;
		if (api.connectionType != 'wifi' && api.connectionType != 'none') {
        	api.confirm({
                title: '提示',
                msg: '您当前处于移动数据网络下，是否继续播放',
                buttons: ['确定', '取消']
            }, function(ret, err) {
                var index = ret.buttonIndex;
                if (index == 1) {//确定
                    toBaiDuPlayer(data.is_encr, data.baidu_cloud_id_url, data.rid, data.title, data);
                }
            });
        }else{
        	toBaiDuPlayer(data.is_encr, data.baidu_cloud_id_url, data.rid, data.title, data);
        }
	}
	function toBaiDuPlayer(is_encr, baidu_cloud_id_url, path, title, videoParam){
		if (api.connectionType == 'none') {//暂无网络
			api.toast({
				msg: '暂无网络，无法访问该资源'
			});
			return;
		}
		if(path != null && path != '' && path.indexOf("http://") < 0 ){
			path = 'http://bos.cfnet.org.cn' + path;
		}
		var videoPath = path;
		// console.log('baidu_cloud_id_url:'+baidu_cloud_id_url+'\n'+'videoPath:'+videoPath+'\n'+'is_encr:'+is_encr);
		if (is_encr == 2) {//转码
			videoPath = baidu_cloud_id_url;
			console.log("播放地址:"+videoPath);
			sendBuriedNotifi('0', 'mooc视频', '009',videoParam.vid);
			api.openWin({useWKWebView:true,
				name: 'BaiDuWebVideo',
				url: '../Study/BaiDuWebVideo.html',
				pageParam: {
					title: title,
					url: videoPath,
					token: '',
					videoParam: videoParam
				},
				slidBackEnabled: false
			});
		}else{
			sendBuriedNotifi('0', 'mooc视频', '009',videoParam.vid);
			api.openWin({useWKWebView:true,
				name: 'BaiDuWebVideo',
				url: '../Study/BaiDuWebVideo.html',
				pageParam: {
					title: title,
					url: videoPath,
					token: '',
					videoParam: videoParam
				},
				slidBackEnabled: false
			});
		}
		// if (path != '') {
		// 	   	sendBuriedNotifi('0', 'mooc视频', '009',videoParam.vid);
		// 		study_courseTimeRecordFun(videoParam, 'NONE', 'false');
		// 	var CFBaiDuVideo = api.require('CFBaiDuVideo');
		//        CFBaiDuVideo.initVideo({
		//           title : title,
		//           path : videoPath,
		//           isShowFullScreenBtn : 1,
		//           isShowFullScreen : 1,
		//           token : ''
		//        },function(ret, err){
		//        	sendBuriedNotifi('1', 'mooc视频', '009',videoParam.vid);
		//        	study_courseTimeRecordFun(videoParam, 'NONE', 'true');
		//        });
		// }else{
		// 	if (is_encr == 1 || is_encr == 2) {//加密
		// 		videoPath = baidu_cloud_id_url;newtrain/course/getCourseList
		// 		getVideoToken(function(status, videoToken){
		// 			// console.log('videoToken:'+videoToken+'\n'+'videoPath:'+videoPath);
		// 		    sendBuriedNotifi('0', 'mooc视频', '009',videoParam.vid);
		// 			study_courseTimeRecordFun(videoParam, 'NONE', 'false');
		// 			var CFBaiDuVideo = api.require('CFBaiDuVideo');
		// 	        CFBaiDuVideo.initVideo({
		// 	           title : title,
		// 	           path : videoPath,
		// 	           isShowFullScreenBtn : 1,
		// 	           isShowFullScreen : 1,
		// 	           token : videoToken
		// 	        },function(ret, err){
		// 	          sendBuriedNotifi('1', 'mooc视频', '009',videoParam.vid);
		// 	        	study_courseTimeRecordFun(videoParam, 'NONE', 'true');
		// 	        });
		//         });
		// 	}else{
		// 		api.toast({
		// 		    msg: '视频播放失败！'
		// 		});
		// 	}
		// }
	}
	function sendBuriedNotifi(busionessid, pagetype, pagetypeid,vid) {
		var userinfo = {
			uid : $api.getStorage('cfnetppuid'),
			jid : $api.getStorage('cfnetppjxid'),
			uname : $api.getStorage('cfnetppusername'),
			cid : api.pageParam.courseid,
			pid : api.pageParam.pid,

		}
		var data = {
			busionessid : busionessid,
			pagetype : pagetype,
			pagetypeid : pagetypeid,
			sourceurl : api.pageParam.sourceurl,
			sourcetitle : api.pageParam.sourcetitle,
			accesspageurl : window.location.pathname,
			accesspagetitle : document.title,
			userinfo : userinfo
		}
		if(vid!=""){
			userinfo["vid"]=vid;
			data["accesspagetitle"]="Mocc视频章节";
		}
		SendBehaviorTrajectoriesNotifi_Study(data);
	}
	function openTest(data){
		data["type"] = 0;
		api.openWin({useWKWebView:true,
		    name: 'New_student_study_freecourse_TestExam',
		    url: '../Study/New_student_study_freecourse_TestExam.html',
		    bounces: false,
		    pageParam: data,
		    slidBackEnabled :false
		});
	}
	function openHDResource(data){
		data["ismocc"] = 1;
		api.openWin({useWKWebView:true,
		    name: 'student_study_freecourse_interactiveNew',
		    url: '../Study/student_study_freecourse_interactiveNew.html',
		    bounces: false,
		    pageParam: data,
		    bgColor: '#fff'
		});
	}
	function openRichText(data){
		api.openWin({useWKWebView:true,
		    name: 'studyCourseRichtextNew',
		    url: '../Study/studyCourseRichtextNew.html',
		    bounces: false,
		    pageParam: data,
		    bgColor: '#fff'
		});
	}
	function openDoc(data){
		data["doc"] = data.rid;
		var is_encr = data.is_encr;
		if (is_encr == 1) {//加密
			var baidu_cloud_id = data.baidu_cloud_id;
			api.openWin({useWKWebView:true,
			    name: 'StudyWebBaiDuDoc_win',
			    url: '../Study/StudyWebBaiDuDoc_win.html',
			    pageParam: {
			        docId: baidu_cloud_id,
			        title: data.title,
			        studyParam: data
			    }
			});
		}else{
			api.openWin({useWKWebView:true,
			    name: 'studyCourseDoc',
			    url: '../Study/studyCourseDoc.html',
			    bounces: false,
			    pageParam: data,
			    bgColor: '#fff'
			});
		}
	}
	function chapterCellHtml(index, tagIndex, chapterIndex, data){
		var chapterClass = '';
		var chapterStatusHtml = '<span class="list-iconbox"><img src="../../image/icon_suo.png"/></span>';
		var isFree = 0;
		if (buyStatus == 1) {
			chapterClass = 'list-freecourse';
			chapterStatusHtml = '';
			isFree = 1;
		}else{
			if (tagIndex == 1 && chapterIndex == 1) {//第一章第一课时可以看
				chapterClass = 'list-freecourse';
				chapterStatusHtml = '<span class="list-iconbox">可试学</span>';
				isFree = 1;
			}
		}
		var content_type = data.content_type;
		var type_name = '';
		if (content_type == 'hdresource') {
			type_name = '互动资源';
		}else if(content_type == 'discuss'){
			type_name = '讨论';
		}else if(content_type == 'tests'){
			type_name = '测验';
		}else if(content_type == 'richtext'){
			type_name = '富文本';
		}else if(content_type == 'video'){
			type_name = '视频';
		}else if(content_type == 'doc'){
			type_name = '文档';
		}
		return '<ul index="'+index+'" isFree="'+isFree+'" class="listbox chapter-cell">'+
					'<li class="list-item '+chapterClass+'">'+
						'<span class="list-labelbox"><span>'+type_name+'</span></span>'+
						'<a class="list-title">'+data.cdetailtitle+'</a>'+
						chapterStatusHtml+
					'</li>'+
				'</ul>';
	}
	function tagCellHtml(index, tagIndex, data){
		var classStr = '';
		if (tagIndex == 1) {//如果第一个章则添加class
			classStr = 'first-section';
		}
		var chapter_name = '第'+tagIndex+'章：'+data.cdetailtitle;
		return '<div index="'+index+'" class="course-listcont course-section '+classStr+'">'+
					'<p class="course-tit">'+chapter_name+'</p>'+
				'</div>';
	}
	function partCellHtml(index, partIndex, data){
		var chapter_name = '第'+partIndex+'节：'+data.cdetailtitle;
		return '<div index="'+index+'" class="course-listcont jie-tit-div">'+
					'<p class="course-tit">'+chapter_name+'</p>'+
				'</div>';
	}
	//加载评论数据
	function loadCommentData(){
		var params = {
			cid : api.pageParam.id,
			uid : $api.getStorage('cfnetppuid'),
			page : page,
			rows : rows
		}
		cfnetppPOST(url_train_getCourseComments, params, true, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					if (page = 1) {
						commentArr = new Array();
						$('#comment_list').html('');
						$('#noData2').hide();
						$('#noNet2').hide();
					}
					var comments = data.data.data;
					if (comments != undefined && comments != null && comments.constructor == Array && comments.length > 0) {
						dropRefreshCount = comments.length;
						setupCommentData(comments);
					}else{
						if(page = 1){
							$('#noData2').show();
							$('#noNet2').hide();
						}
					}
				}else{
					if(page = 1){
						$('#chapter_list').html('');
						$('#noData2').show();
						$('#noNet2').hide();
					}
				}
			}else{
				if(page = 1){
					$('#chapter_list').html('');
					$('#noData2').hide();
					$('#noNet2').show();
				}
			}
		});
	}
	function setupCommentData(arr){
		var oldCount = commentArr.length;
		commentArr = commentArr.concat(arr);
		var newCount = commentArr.length;
		for (var i = oldCount; i < newCount; i++) {
			var commentData = commentArr[i];
			$('#comment_list').append(commentCellHtml(i, commentData));
			var uid = commentData.uid;
			loadUserInfo(uid, function(status, userInfo){
				if (status) {
					var username = userInfo.username;
					var userprofile = userInfo.userprofile;
					$('#name_uid_'+uid).text(username);
					$('#icon_uid_'+uid).attr('src', userIcon(userprofile));
				}
			});//设置评论人信息
		}
	}
	function userIcon(iconPath){
		if (iconPath == undefined || iconPath == null || iconPath == '') {
			return '../../image/default_user_icon.png';
		}
		return iconPath;
	}
	//星星字符串
	function starHtml(num){
		num1 = 5 - num;
		var starHtmlStr = '';
		for (var i = 0; i < num; i++) {
			starHtmlStr += starOnHtml();
		}
		for (var i = 0; i < num1; i++) {
			starHtmlStr += starOffHmtl();
		}
		return starHtmlStr;
	}
	//选中的星星
	function starOnHtml(){
		return '<span class="icon-star icon-star-on"></span>';
	}
	//未选中的星星
	function starOffHmtl(){
		return '<span class="icon-star"></span>';
	}
	function commentCellHtml(index, data){
		var star_num = data.star;
		return '<div index="'+index+'" class="judge-item comment-cell">'+
					'<div class="judge-item-top">'+
						'<div class="judge-userimg"><img id="icon_uid_'+data.uid+'" src="../../image/expimg01.png"/></div>'+
						'<div class="judge-infobox">'+
							'<div class="clearfix">'+
								'<p id="name_uid_'+data.uid+'" class="judge-username">(未知用户)</p>'+
								'<span class="judge-info-time">'+timeStringWithTimeStamp(data.createtime)+'</span>'+
							'</div>'+
							'<div class="starbox">'+
								starHtml(star_num)+
							'</div>'+
						'</div>'+
					'</div>'+
					'<div class="judge-item-txt">'+data.content+'</div>'+
				'</div>';
	}
	function loadUserInfo(uid, callback){
		var params =  {
			uid : uid
		}
		// console.log(uid+'\n'+urlApplst);
		cfnetppPOST(urlApplst, params, true, function(data, status){
			if (status == 'success') {
				if (data.status == '1') {
					var userInfo = data.json;
					if (callback) {
						callback(true, userInfo);
						return;
					}
				}
			}
			if (callback) {
				callback(false, null);
			}
		});
	}
	function setupCourseData(data){
		currentCid = data.course_id;
		loadChapterData();
		$('#course_image').attr('src', data.course_image);
		$('#course_name').text(data.course_name);
		$('#teachername').text(data.teachername);
		$('#learn_num').text(data.learn_num+'人学过');
		$('#course_period').text(data.course_period+'课时');
		$('#course_fee').text('￥'+data.course_fee);
		$('#course_describe').html(data.course_describe);
		$('#teacherinfo').html(data.teacherinfo);
		$('#buyinfo').html(data.course_notes);
		var star_num = data.star_num;
		for (var i = 0; i < star_num; i++) {
			var index = i + 1;
			$('#star'+index).addClass('icon-star-on');
		}
	}
	function backClick(){
		api.closeWin();
	}
	function submitCommentClick(comment){
		var params = {
			cid : api.pageParam.id,
			uid : $api.getStorage('cfnetppuid'),
			star : currentScore,
			content : comment
		};
		// console.log(JSON.stringify(params)+'\n'+url_train_addComment);
		cfnetppPOST(url_train_addComment, params, false, function(data, status){
			if (status == 'success') {
				if (data.code == 200) {
					page = 1;
					loadCommentData();
				}else{
					api.toast({
					    msg: data.message
					});
				}
			}else{
				api.toast({
				    msg: '网络异常'
				});
			}
		});
	}
	function buyCourse(){
		api.openWin({useWKWebView:true,
		    name: 'signup-kc',
		    url: 'signup-kc.html',
		    pageParam: courseData
		});
	}
	function onShareClick(){
		onScreenCapture('current_page', function(status, imgPath){
			$('#share_img').attr('src', imgPath);
			createShareImage('share_img_div', function(status2, imgPath2){
				screenCapturePath = imgPath2;
				// setInterval(function () {
				// 	$("#share_div").hide();
				// },1500);
				$(".shareshade").show();
				$(".sharelay").css("bottom","0px");
				$("#share_div").show();
			});
		});
	}
	function onCancelClick(){
		$(".shareshade").hide();
		$(".sharelay").css("bottom","-100%");
		$("#share_div").hide();
	}
</script>
</html>